<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>外边距典型应用-块级盒子水平居中</title>
    <style>
        .header{
            width: 900px;
            height: 200px;
            background-color: aqua;
            margin: 100px auto;
            /* 100px是距离顶部100px，auto自动居中 */
            text-align: center;
        }
        
    </style>
</head>
<body>
    <div class="header">文字</div>
    <div class="header"><img src="img/块级盒子水平居中方法.png" alt=""></div>
</body>
</html>